function display() {
  echo "$1 assignments..."
  mysql -u root timesheets_development < /tmp/assignments.sql
  echo "$1 worklogs..."
  mysql -u root timesheets_development < /tmp/worklogs.sql
}

cat > /tmp/test.sql << EOF
insert into worklogs set worker_id = 1, project_id = 1;
insert into worklogs set worker_id = 1, project_id = 2;
insert into worklogs set worker_id = 2, project_id = 1;
insert into assignments set user_id = 1, project_id = 1;
insert into assignments set user_id = 2, project_id = 1;
insert into assignments set user_id = 1, project_id = 2;
EOF

cat > /tmp/assignments.sql << EOF
select * from assignments;
EOF
cat > /tmp/worklogs.sql << EOF
select * from worklogs;
EOF

mysql -u root timesheets_development < db/drop_all.sql
rake migrate VERSION=1
mysql -u root timesheets_development < /tmp/test.sql
display "Before upgrade to V2"
rake migrate VERSION=2
display "After upgrade to V2"
rake migrate VERSION=1
display "After downgrade to V1"

